﻿@model Shop.Wares.Models.AnyWares
@{
    //商品详情页
    ViewBag.Title = Model.WName;
    Layout = "~/Views/Home/_HomeLayout.cshtml";
}
<div class="main-container container">
    <ul class="breadcrumb">
        <li><a href="#"><i class="fa fa-home"></i></a></li>
        <li><a href="Category-@(Model.CID)-0">@Model.CName</a></li>
        <li><a href="Category-@(Model.CID)-@(Model.SCID)">@Model.SCName</a></li>
        <li><a href="#">@Model.WName</a></li>
    </ul>

    <div class="row">
        <!--Middle Part Start-->
        <div id="content" class="col-md-12 col-sm-12">

            <div class="product-view row">
                <div class="left-content-product col-lg-10 col-xs-12">
                    <div class="row">
                        <div class="content-product-left class-honizol col-sm-6 col-xs-12 ">
                            <!--大图片-->
                            <div class="large-image" style="width:100%;height:0px;padding-bottom:100%;position:relative;" >
                                <img  class="product-image" src="@Model.Url"  title="@Model.WName" alt="@Model.WName" style=" width:100%;height:100%;position:absolute;">
                            </div>
                        </div>
                        <div class="content-product-right col-sm-6 col-xs-12">
                            <div class="title-product">
                                <h1>@Model.WName</h1>
                            </div>

                            <div class="product-box-desc">
                                <div class="inner-box-desc">
                                    <div class="price-tax"><span></span></div>
                                </div>
                            </div>
                            <div class="product-label form-group">
                                <div class="product_page_price price" itemprop="offerDetails" itemscope="" itemtype="http://data-vocabulary.org/Offer">
                                    <span class="price-new" itemprop="price">现价:@Model.PPrice</span>
                                    <span class="price-old">原价:@Model.OPrice</span>
                                </div>
                                <div class="stock"><span>库存:</span> <span class="status-stock">@Model.Stock</span></div>
                            </div>
                            <div class="product-box-desc">
                                <div class="inner-box-desc">
                                    <div class="price-tax"><span>商品说明:</span>@Model.Describe</div>
                                </div>
                            </div>
                            <div id="product">
                                <div class="form-group box-info-product">
                                    <div class="option quantity">
                                        <!--选数量的框-->
                                        <div class="input-group quantity-control" unselectable="on" style="-webkit-user-select: none;">
                                            <label>数量</label>
                                            <input class="form-control" type="text" name="BuyNum" id="BuyNum"
                                                   value="1" style="width:50px">
                                            <input type="hidden" name="product_id" value="@Model.Stock">
                                            <span class="input-group-addon product_quantity_down">−</span>
                                            <span class="input-group-addon product_quantity_up">+</span>
                                        </div>
                                    </div>
                                    <div class="cart">
                                        <input type="button" data-toggle="tooltip" title="" value="添加到购物车" data-loading-text="Loading..." id="button-cart" class="btn btn-mega btn-lg" onclick="addshopcars('@Model.WID','@Model.WName','@Model.Url')" data-original-title="添加到购物车">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                @*<section class="col-lg-2 hidden-sm hidden-md hidden-xs slider-products">
                    <div class="module col-sm-12 four-block">
                        <div class="modcontent clearfix">
                            <div class="policy-detail">
                                <div class="banner-policy">
                                    <div class="policy policy1">
                                        <a href="#">
                                            <span class="ico-policy">&nbsp;</span>90天<br>退款
                                        </a>
                                    </div>
                                    <div class="policy policy2">
                                        <a href="#"> <span class="ico-policy">&nbsp;</span>店内交流</a>
                                    </div>
                                    <div class="policy policy3">
                                        <a href="#"> <span class="ico-policy">&nbsp;</span>价格最低</a>
                                    </div>
                                    <div class="policy policy4">
                                        <a href="#"> <span class="ico-policy">&nbsp;</span>购物保证</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>*@
            </div>

            <!-- Product Tabs -->
            <div class="producttab ">
                <div class="tabsslider  vertical-tabs col-xs-12">
                    <ul class="nav nav-tabs col-lg-2 col-sm-3">
                        <li class="active"><a data-toggle="tab" href="#tab-1">商品描述</a></li>
                        <li class="item_nonactive"><a data-toggle="tab" href="#tab-review">查看评论</a></li>
                    </ul>
                    <div class="tab-content col-lg-10 col-sm-9 col-xs-12">
                        <div id="tab-1" class="tab-pane fade active in">
                            @Html.Raw(Model.Introduce)
                        </div>
                        <!--评论的-->
                        <div id="tab-review" class="tab-pane fade">
                            <form>
                                <div id="review">
                                    <table class="table table-striped table-bordered">
                                        <tbody>
                                            <tr>
                                                <td style="width: 50%;"><strong>评论一览</strong></td>
                                                @*<td class="text-right">03/05/2020</td>*@
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <p>您可以根据评论进行选择与购买</p>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <div class="text-right"></div>
                                </div>
                                @*<h2 id="review-title">Write a review</h2>*@
                                <div class="contacts-form">
                                    <ul class="megamenu">
                                        @{IList<Shop.Wares.Models.Comments> comments = new Shop.Wares.Repositories.CommentsAccess().GetComments(Model.WID);
                                            Shop.User.Services.UsersAccess usersAccess = new Shop.User.Services.UsersAccess();}
                                        @foreach (var item in comments)
                                        {
                                            <li class="item-vertical css-menu with-sub-menu hover">
                                                <p class="close-menu"></p>
                                                <a href="#" style="color:black">
                                                    <span>@item.CommentDate</span>
                                                    <br />
                                                    <span>@usersAccess.SelectUserByid(item.UID).UName 发表的评论：</span>
                                                    <span>@item.Comment</span>

                                                    <b class="caret"></b>
                                                </a>
                                            </li>
                                        }
                                    </ul>
                                </div>
                            </form>
                        </div>
                        
                    </div>
                </div>
            </div>
            @Html.Action("_WaresTopCategory", "Home", new { CID = Model.CID, Top = 5, CName = "相关产品" })
        </div>


    </div>
</div>

<script type="text/javascript">
    //加入购物车
    function addshopcars(WID,WName,Url)
    {
        var BuyNum = $("#BuyNum").val();
        if (BuyNum > @Model.Stock)
        {
            alert("购买数量不能大于库存");
            return false;
        }
         $.ajax({
            type: 'post',//方式
            url: '@Url.Action("AddShopCar")',
            data: { WID: WID, BuyNum: $("#BuyNum").val() },
            dataType: 'text',//返回数据格式
            success: function (data) {
                if (data == 'NO1') {
                    alert("库存不足");
                    return false;
                }
                if (data == 'NO')
                {
                    alert("添加失败");
                    return false;
                }
                if (data == "User")
                {
                    alert("无效的用户状态，请重新登陆");
                    location.href = "@Url.Action("UsersLogin","User")";
                    return false;
                }
                else
                {
                    cart.add(WName, Url);
                    HomeShopCar();
                }
            },
            error: function () {
                alert("Ajax调用出错请与管理员联系");
            }
        });
    }
    //加入购物车
    function addshopcar(WID, WName, Url)
    {
         $.ajax({
            type: 'post',//方式
            url: '@Url.Action("AddShopCar")',
            data: { WID: WID, BuyNum:1},
            dataType: 'text',//返回数据格式
            success: function (data) {
                if (data == 'NO1') {
                    alert("库存不足");
                    return false;
                }
                if (data == 'NO')
                {
                    alert("添加失败");
                    return false;
                }
                if (data == "User")
                {
                    alert("无效的用户状态，请重新登陆");
                    location.href = "@Url.Action("UsersLogin","User")";
                    return false;
                }
                else
                {
                    cart.add(WName, Url);
                    HomeShopCar();
                }
            },
            error: function () {
                alert("Ajax调用出错请与管理员联系");
            }
        });
    }
</script>
